package com.fau.wm.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 消费者购买力统计实体类
 * @author kangyj
 * @datetime 2014年11月10日,上午10:45:25
 */
@Entity
@Table(name = "medical_ss_purchase")
public class MedicalSsPurchase implements Serializable, JSONAware {
	
	private static final long serialVersionUID = 1264901958825953717L;
	
	private String id;
	private String name;			// 姓名
	private Integer age;			// 年龄
	private String sex;				// 性别
	private String level;			// 会员级别
	private String phoneNum;		// 客户电话
	private Date ordersDate;		// 下单时间
	private String medicineSort;	// 药品类别名称
	private String illness;			// 疾病
	private String cityId;			// 城市id
	private String cityName;		// 城市名
	private BigDecimal ordersMoney;	// 订单金额
	private String customerId;		// 客户id
	private String ordersId;		// 订单id
	private String medicineSortId;	// 药品类别id
	private String hospitalId;		// 医院企业id
	
	// 以下为临时字段
	private String centerId;		// 中心id
	private String groupId;			// 组id
	private String userId;			// 话务员id
	
	private String startTime;		// 开始时间
	private String endTime;			// 结束时间
	private Integer startMoney;		// 开始排名
	private Integer endMoney;		// 结束排名
	private BigDecimal totalAmount;	// 总金额
	
	private Integer countBuy;		// 购买次数 
	private String keyPid;			// 字典表父id
	private String keyType;			// 字典表类型
	
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name = "name", length = 10)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "age", length = 3)
	public Integer getAge() {
		return age;
	}
	
	public void setAge(Integer age) {
		this.age = age;
	}
	
	@Column(name = "sex", length = 5)
	public String getSex() {
		return sex;
	}
	
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Column(name = "level", length = 10)
	public String getLevel() {
		return level;
	}
	
	public void setLevel(String level) {
		this.level = level;
	}
	
	@Column(name = "phone_num", length = 20)
	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	@Column(name = "orders_date")
	public Date getOrdersDate() {
		return ordersDate;
	}
	
	public void setOrdersDate(Date ordersDate) {
		this.ordersDate = ordersDate;
	}
	
	@Column(name = "medicine_sort", length = 255)
	public String getmedicineSort() {
		return medicineSort;
	}
	
	public void setMedicineSort(String medicineSort) {
		this.medicineSort = medicineSort;
	}
	
	@Column(name = "illness", length = 32)
	public String getIllness() {
		return illness;
	}
	
	public void setIllness(String illness) {
		this.illness = illness;
	}
	
	@Column(name = "city_id", length = 20)
	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	@Column(name = "city_name", length = 30)
	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	@Column(name = "orders_money", length = 10)
	public BigDecimal getOrdersMoney() {
		return ordersMoney;
	}
	
	public void setOrdersMoney(BigDecimal ordersMoney) {
		this.ordersMoney = ordersMoney;
	}
	
	@Column(name = "customer_id", length = 32)
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	@Column(name = "orders_id", length = 32)
	public String getOrdersId() {
		return ordersId;
	}

	public void setOrdersId(String ordersId) {
		this.ordersId = ordersId;
	}
	
	@Column(name = "medicine_sort_id", length = 255)
	public String getMedicineSortId() {
		return medicineSortId;
	}

	public void setMedicineSortId(String medicineSortId) {
		this.medicineSortId = medicineSortId;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}
	
	@Transient
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Transient
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}
	
	@Transient
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Transient
	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	@Transient
	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	
	@Transient
	public Integer getStartMoney() {
		return startMoney;
	}

	public void setStartMoney(Integer startMoney) {
		this.startMoney = startMoney;
	}

	@Transient
	public Integer getEndMoney() {
		return endMoney;
	}

	public void setEndMoney(Integer endMoney) {
		this.endMoney = endMoney;
	}

	@Transient
	public BigDecimal getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(BigDecimal totalAmount) {
		this.totalAmount = totalAmount;
	}

	@Transient
	public Integer getCountBuy() {
		return countBuy;
	}

	public void setCountBuy(Integer countBuy) {
		this.countBuy = countBuy;
	}
	
	@Transient
	public String getKeyPid() {
		return keyPid;
	}

	public void setKeyPid(String keyPid) {
		this.keyPid = keyPid;
	}

	@Transient
	public String getKeyType() {
		return keyType;
	}

	public void setKeyType(String keyType) {
		this.keyType = keyType;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", id);
		obj.put("name", name);
		obj.put("age", age);
		obj.put("sex", sex);
		obj.put("level", level);
		obj.put("phoneNum", phoneNum);
		obj.put("medicineSort", medicineSort);
		obj.put("illness", illness);
		obj.put("cityId", cityId);
		obj.put("cityName", cityName);
		obj.put("totalAmount", totalAmount);
		if(null != ordersDate) {
			obj.put("ordersDate", DateFormatUtils.format(ordersDate, "yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("ordersMoney", ordersMoney);
		obj.put("countBuy", countBuy);
		return obj.toString();
	}
	

}
